<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>淘格子，淘分享</title></head>
<script  language="javascript">
var publicMsgid;

window.addEvent('domready', function() {   

   	//初始化显示任务细节的格子
	for(i=0;i<24;i++)
	{
	var obj ='gettask'+(i+1).toString();
		$(obj).setStyles({width:'80px',height:'55px','background-color': '#E0ECFF',margin: '2px 1px 2px 2px'});		
	}
			
});	

//发送消息给指定用户名，只能发给团队内部成员
function sendMsg(target,msgs)
{
	var callback = function(data){	
		if(data[0]['status']=='ok')
		{
			msg('Notice','Send it');
			$j('#winmsgsend').window('close');
		}
		else
		{
		$j.messager.alert('出错了','服务器存取错误,请重试或者联系客服');
		
		}
	};
	var datastr = 'target='+target+'&msg='+msgs+'&kind=Reply';
	var urlstr = '__APP__/Util/sendMsg';
	var myid = parseInt(Cookie.read('id_user__'));
	if(myid!=parseInt(target))
	ajaxGet(urlstr,datastr,callback); 
	else
	$j.messager.alert('出错了','不可给自己发消息');
	$j('#winmsgsend').window('close');
	
}

function readMsg(msgid)
{	
	var callback = function(data){	
		if(data[0]['status']=='ok')
		{
			msg('Notice','Read it');
		}
		else
		{
		$j.messager.alert('出错了','服务器存取错误,请重试或者联系客服');
		
		}
	};
	var datastr = 'id_gezi_msg='+msgid;
	var urlstr = '__APP__/Util/readMsg';
	ajaxGet(urlstr,datastr,callback);
}

//消息体内包含的js函数，其他参数可以陆续添加代码
function readMe(clas,type)
{	msgid = publicMsgid;
	switch(type)
   {
   case 'shareTask':
		 {
		var id_task = $(msgid+'attach2').innerHTML.split(':')[1];
		var taskpage =$(msgid+'attach3').innerHTML.split(':')[1];
		var url = '__APP__/Task/preShareTask?id_task='+id_task+'&taskpage='+taskpage;
		//要根据idtask获得任务的所有商品图片和链接，让领取人查看是否有竞争性商品，再决定是否领取
			var urlstr = '__APP__/Util/getTaskprjpdtinfo';
			seeTask('gettask',id_task,urlstr);
			$j('#winShareTask').load(url);
			$j('#winShareTask').window('open');			

			$j('#winwindivid').window('open');
			$j('#winwindivid').window('move',{left: 250});
			$j('#winShareTask').window('move',{left: 630});			
		 }
	 break
   case 2:
		{}
	 break
   default:
	 
   }
}

//尝试申请一个任务份额的提交界面
function getSharetaskn(){
	//对提交数量加一个confirm确认
	var taskid =  $('wintaskid').innerHTML.split(':')[1];
	var tp =  $('wintaskpage').innerHTML.split(':')[1];
	var tnp =  $('wintaskNpage').innerHTML.split(':')[1];
	var pnc =  $('winperNC').innerHTML.split(':')[1];
	var aplycount =  $('wingettaskcount').value;
	var id_team = $('winteamid').innerHTML.split(':')[1];
	var datastr = 'id_task='+taskid+'&count='+aplycount+'&id_team='+id_team;

	var urlstr = '__APP__/Task/getTaskCount';

		var callback = function(data){	
		$j('#winShareTask').window('close');
		if(data[0]['status']=='ok')
		{
		$j('#winwindivid').window('close');
		$j.messager.alert('申请数量通过啦','恭喜你，成功领取任务张数：'+aplycount);
		}
		else
		{
		$j.messager.alert('出错了','服务器存取错误,请重试或者联系客服');
		
		}
	};

	if(parseInt(tnp)<=0)
	{
	$j.messager.alert('任务已被其他队员领取完毕','任务不可领取,下次早点来');
	}
	else
	if(parseInt(aplycount)>parseInt(tnp))
	{
	$j.messager.alert('超过可申请数量','可领取:'+tnp+',你申请了:'+aplycount);
	}
	else
	if(parseInt(aplycount)>parseInt(pnc))
	{
	$j.messager.alert('超过你的能力范围','可用能力:'+pnc+',你申请了:'+aplycount);
	}
	else
	{
	ajaxGet(urlstr,datastr,callback);
	}	
	
}

//回复消息
function answerMsg(id)
{
	var id = id.substring(3);

	var from = parseInt($(id+'from_id_usert').innerHTML);
	$('ttgt').value = from; 
	
	if( (from!=0) )
	{
	$j('#winmsgsend').window('open');
	}
	else
	{
	$j.messager.alert('提醒','不可回复系统消息');
	}
}


//点击行
function clickrow(idd,clas)
{
var length = clas.length;
var id= idd.substr(length);
publicMsgid = id;
//所有行颜色统一
$j('.'+clas+'tr').css('backgroundColor','#e7efff');

//当前行颜色变色
$j('#'+clas+id).css('backgroundColor','#FFCC00');

$j('.'+clas).hide('slow');
$j('#'+clas+'div'+id).show('slow');
var jaj = id+'status'+clas;

	if($(id+'status'+clas).innerHTML=='tobeCheck')
	{
	readMsg(id);
	$(id+'status'+clas).innerHTML = 'OK';
	}
}


</script>
<body  style="text-align:center;"><center>
<br/>
<!--panel-->
<div id="msginfo" title="消息通知" class="easyui-panel"   style="width:795px;height:600px;padding:10px;" collapsible="true"> 
	<div  class="easyui-tabs" style="height:550px;">
			<div id="tab1" title="已发消息">
			<!--		<!--数据集显示begin---->	
			<php>$rttary = getbbsList($_SESSION['UserInfo']['id'],'',''); $msgList = $rttary['a'];$msgpage =$rttary['b']; </php>
						<br/>
			<table  bgcolor="#e7efff" border="1" style="margin-top:0px; font-size:12; width:600px;" cellspacing="1" cellpadding="1">
                    <tr>
                        <td bgcolor="#FFD700">ID</td>
                        <td bgcolor="#FFD700">状态</td>						
                        <td bgcolor="#FFD700">From</td>						
                        <td bgcolor="#FFD700">to</td>
	                    <td bgcolor="#FFD700">附属</td>
                        <td bgcolor="#FFD700">其他</td>						
                        <td bgcolor="#FFD700">类别</td>																																																																	
                    </tr>
						<div id="list" >
                          <volist name="msgList" id="vo">
                            <tr  class="sendtr" id="send{$vo.id_gezi_msg}"  onClick="clickrow(this.id,'send');">
							  <td id="{$vo.id_gezi_msg}">{$vo.id_gezi_msg}</td>
                              <td id="{$vo.id_gezi_msg}statussend">{$vo.status}</td>							  
                              <td id="{$vo.id_gezi_msg}from_id_user">{$vo.from_id_user}</td>							  
                              <td id="{$vo.id_gezi_msg}to">{$vo.target}</td>
                              <td id="{$vo.id_gezi_msg}attach1">{$vo.attach1}</td>
                              <td id="{$vo.id_gezi_msg}attach2">{$vo.attach2}</td>							  							  
                              <td id="{$vo.id_gezi_msg}msgkind">{$vo.msgkind}</td>	
                            </tr>
							
							<tr><td colspan="9">
						   <div  class="send" id="senddiv{$vo.id_gezi_msg}" style="display: none">{$vo.msg}</div></td>
							</tr>
                          </volist>

                        </div>
					<tr>
                    <td align="center" colspan="13">		
					<?php
					if(isset($msgpage)) echo $msgpage;		
					?>	</td>
                    </tr>
		  	</table>
		<!--数据集显示结束-->

			</div>
			
			
			<div id="tab2" title="收到消息">
		<!--<!--数据集显示begin---->	
			<php>$rttary = getbbsList('',$_SESSION['UserInfo']['id'],''); $msgList = $rttary['a'];$msgpage =$rttary['b']; </php>
			<br/>
			<table  bgcolor="#e7efff" border="1" style="margin-top:0px; font-size:12;width:600px;" cellspacing="1" cellpadding="1">
                    <tr>
                        <td bgcolor="#FFD700">ID</td>
                        <td bgcolor="#FFD700">状态</td>						
                        <td bgcolor="#FFD700">From</td>						
                        <td bgcolor="#FFD700">to</td>
	                    <td bgcolor="#FFD700">附属1</td>
                        <td bgcolor="#FFD700">附属2</td>						
                        <td bgcolor="#FFD700">附属3</td>												
                        <td bgcolor="#FFD700">类别</td>																																																																	
						<td bgcolor="#FFD700">回复</td>
                    </tr>
						<div id="list" >
                          <volist name="msgList" id="vo">
                            <tr class="receivetr" id="receive{$vo.id_gezi_msg}"  onClick="clickrow(this.id,'receive');" >
							  <td id="{$vo.id_gezi_msg}id">{$vo.id_gezi_msg}</td>
                              <td id="{$vo.id_gezi_msg}statusreceive">{$vo.status}</td>							  
                              <td id="{$vo.id_gezi_msg}from_id_usert">{$vo.from_id_user}</td>							  
                              <td id="{$vo.id_gezi_msg}to">{$vo.target}</td>
                              <td id="{$vo.id_gezi_msg}attach1">{$vo.attach1}</td>
                              <td id="{$vo.id_gezi_msg}attach2">{$vo.attach2}</td>	
                              <td id="{$vo.id_gezi_msg}attach3">{$vo.attach3}</td>								  						  							  
                              <td id="{$vo.id_gezi_msg}msgkindt">{$vo.msgkind}</td>	
                              <td id="agt{$vo.id_gezi_msg}" onClick="answerMsg(this.id)"><img src="__PUBLIC__/Images/edit.ico" alt="回复"/></td>
                            </tr>
							<tr><td colspan="9">
						   <div  class="receive" id="receivediv{$vo.id_gezi_msg}" style="display: none">{$vo.msg}</div></td>
							</tr>
                          </volist>

                        </div>
					<tr>
                    <td align="center" colspan="13">		
					<?php
					if(isset($msgpage)) echo $msgpage;		
					?>	</td>
                    </tr>
		  	</table>
		<!--数据集显示结束-->
			</div>
			
	<div id="tab3" title="发送消息">
		<php>$mbList = getMemberlist($_SESSION['UserInfo2']['id_gezi_team']);  </php>
		<br/><br/>
		<div id="sendmsgpl"  class="easyui-panel"   style="width:490px;height:400px;" collapsible="false"> 		
		<br/><br/>
		<label style="font-size:12px">选择发送对象<select  id="selmsgtarget" onChange="">
			  <option value="Team" selected>团队群发</option>	
			  <volist name="mbList" id="vo">
			  <option value="{$vo.id_user}">{$vo.name}</option>
			  </volist>
		  		</select>
		  </label><br/>
		<textarea name="" cols="40" rows="4" id="msgbody">发送消息给指定用户名，只能发给团队内部成员或则群发</textarea><br/>
		<input type="button" id="sendmsg" onClick="sendMsg($('selmsgtarget').value,$('msgbody').innerHTML);" value="发送消息" />
		</div>
	</div>		
	</div>		
</div>



</center>	
	<div id="winmsgsend" class="easyui-window"  closed="true" closable="true" title="回复消息" style="width:350px;height:200px;">
	<br/>
	<textarea id="sendmsgbodyWin" cols="20" rows="5" onClick="if(this.value.length<14)this.value='';" >填写回信信息</textarea><br/>
	<input type="hidden" id="ttgt" />
	<input type="button" value="回复信息" onClick="sendMsg($('ttgt').value,$('sendmsgbodyWin').value);" />
	</div>

	<div id="winShareTask" class="easyui-window"  closed="true"  title="领取任务张数" style="width:365px;height:180px;">
	
	</div>
	
	<div id="winwindivid" class="easyui-window" closed="true"  closable="true" title="任务细节" left=150 style="width:365px;height:470px;">
	<table>
	<tr  bgcolor="#FF9900"><td colspan="4">正面</td> </tr>
	<tr><td><div id="gettask1"></div></td><td><div id="gettask2"></div></td><td><div id="gettask3"></div></td><td><div id="gettask4"></div></td></tr>
	<tr><td><div id="gettask5"></div></td><td><div id="gettask6"></div></td><td><div id="gettask7"></div></td><td><div id="gettask8"></div></td></tr>
	<tr><td><div id="gettask9"></div></td><td><div id="gettask10"></div></td><td><div id="gettask11"></div></td><td><div id="gettask12"></div></td></tr>
	<tr  bgcolor="#FF9900"><td colspan="4">反面</td> </tr>
	<tr><td><div id="gettask13"></div></td><td><div id="gettask14"></div></td><td><div id="gettask15"></div></td><td><div id="gettask16"></div></td></tr>
	<tr><td><div id="gettask17"></div></td><td><div id="gettask18"></div></td><td><div id="gettask19"></div></td><td><div id="gettask20"></div></td></tr>
	<tr><td><div id="gettask21"></div></td><td><div id="gettask22"></div></td><td><div id="gettask23"></div></td><td><div id="gettask24"></div></td></tr>			
	</table>
	</div>
	
</body>